home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / tvtool2.zip / TVVIEWS.INT < prev    next >
Text File  |  1993-07-20  |  11KB  |  373 lines

  1. UNIT TvViews;
  2. {$B+}
  3. {$X+}
  4. {$V-}
  5.  
  6. {$I TVDEFS.INC}
  7.  
  8. INTERFACE
  9.  
  10.  
  11. USES
  12.   TvType, TvConst, TvMenus,
  13.   App, Drivers, Menus, Objects, Views, TextView, Dos;
  14.  
  15.  
  16. CONST
  17.   { Position Indicator palette }
  18.   { 1 = Indicator normal }
  19.   { 2 = Indicator passive }
  20.   { 3 = Indicator dragging }
  21.   CPosIndicator   = #2#3;
  22.  
  23.   { Max/Min button palette }
  24.   { 1 = Button normal }
  25.   { 2 = Button frame normal }
  26.   { 3 = Button dragging }
  27.   CMinMax         = #3#2#3;
  28.  
  29.  
  30. TYPE
  31.   PbxFrame = ^TbxFrame;
  32.   TbxFrame = Object(TFrame)
  33.     Procedure   HandleEvent(var Event: TEvent);           Virtual;
  34.   end;
  35.  
  36.  
  37.   PbxMinMaxButton = ^TbxMinMaxButton;
  38.   TbxMinMaxButton = Object(TView)
  39.     Constructor Init(var Bounds : TRect);
  40.     Procedure   Draw;                                     Virtual;
  41.     Function    GetPalette: PPalette;                     Virtual;
  42.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  43.     Procedure   SetState(AState : Word;
  44.                          Enable : Boolean);               Virtual;
  45.   end;
  46.  
  47.  
  48.   PbxIcon = ^TbxIcon;
  49.   TbxIcon = Object(TView)
  50.     Title : PString;
  51.  
  52.     Constructor Init(ATitle : TTitleStr);
  53.     Constructor Load(var S: TStream);
  54.     Destructor  Done;                                     Virtual;
  55.     Procedure   Draw;                                     Virtual;
  56.     Function    GetPalette: PPalette;                     Virtual;
  57.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  58.     Procedure   SetState(AState : Word;
  59.                          Enable : Boolean);               Virtual;
  60.     Procedure   SizeLimits(var Min, Max : TPoint);        Virtual;
  61.     Procedure   Store(var S: TStream);
  62.   end;
  63.  
  64.  
  65.   PbxWindowIcon = ^TbxWindowIcon;
  66.   TbxWindowIcon = Object(TbxIcon)
  67.     View  : PView;
  68.  
  69.     Constructor Init(ATitle : TTitleStr;
  70.                      AView  : PView);
  71.     Constructor Load(var S: TStream);
  72.     Procedure   ControlMenu(Mouse : Boolean);
  73.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  74.     Procedure   SetState(AState : Word;
  75.                          Enable : Boolean);               Virtual;
  76.     Procedure   Store(var S: TStream);
  77.   end;
  78.  
  79.  
  80.   PbxWindow = ^TbxWindow;
  81.   TbxWindow = Object(TWindow)
  82.     MinMax  : PbxMinMaxButton;
  83.     Icon    : PbxWindowIcon;
  84.  
  85.     Constructor Init(var Bounds : TRect;
  86.                          ATitle : TTitleStr;
  87.                          ANumber: Integer);
  88.     Constructor Load(var S: TStream);
  89.     Procedure   ControlMenu(Mouse : Boolean);
  90.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  91.     Procedure   InitFrame;                                Virtual;
  92.     Procedure   InitIcon;                                 Virtual;
  93.     Procedure   SetState(AState : Word;
  94.                          Enable : Boolean);               Virtual;
  95.     Procedure   Store(var S: TStream);
  96.   end;
  97.  
  98.  
  99.   PbxTextWindow = ^TbxTextWindow;
  100.   TbxTextWindow = Object(TbxWindow)
  101.     Interior    : PTerminal;
  102.     HScrollBar  : PScrollBar;
  103.     VScrollBar  : PScrollBar;
  104.     Width       : Byte;
  105.     Height      : Byte;
  106.  
  107.     Constructor Init(Bounds     : TRect;
  108.                      WinTitle   : String;
  109.                      WinNumber  : Word;
  110.                      AOptions   : Word;
  111.                      AMaxLines  : Word
  112.                     );
  113.     Constructor Load(var S: TStream);
  114.     Procedure   Clear;
  115.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  116.     Procedure   Store(var S: TStream);
  117.     Procedure   Write(St : String);
  118.   end;
  119.  
  120.  
  121.   PbxFormattedTextScroller = ^TbxFormattedTextScroller;
  122.   TbxFormattedTextScroller = Object(TScroller)
  123.     Buf     : PbxCharArray;
  124.     BufSize : Word;
  125.  
  126.     Constructor Init(var Bounds      : TRect;
  127.                          AVScrollBar : PScrollBar;
  128.                          Buff        : PbxCharArray;
  129.                          BuffSize    : Word);
  130.     Constructor Load(var S: TStream);
  131.     Procedure   ChangeBounds(var Bounds: TRect);          Virtual;
  132.     Function    DataSize: Word;                           Virtual;
  133.     Procedure   Draw;                                     Virtual;
  134.     Procedure   GetData(var Rec);                         Virtual;
  135.     Procedure   SetData(var Rec);                         Virtual;
  136.     private
  137.     Procedure   CountLines;
  138.     Procedure   GetNextLine(    First : Word;
  139.                             var Count : Word;
  140.                             var NextCh: Word);
  141.   end;
  142.  
  143.  
  144.   PbxPosIndicator = ^TbxPosIndicator;
  145.   TbxPosIndicator = Object(TView)
  146.     Pos : LongInt;
  147.  
  148.     Constructor Init(var Bounds: TRect);
  149.     Constructor Load(var S: TStream);
  150.     Function    DataSize: Word;                           Virtual;
  151.     Procedure   Draw;                                     Virtual;
  152.     Procedure   GetData(var Rec);                         Virtual;
  153.     Function    GetPalette: PPalette;                     Virtual;
  154.     Procedure   SetState(AState : Word;
  155.                          Enable : Boolean);               Virtual;
  156.     Procedure   SetData(var Rec);                         Virtual;
  157.     Procedure   Store(var S: TStream);
  158.   end;
  159.  
  160.  
  161.   PbxMultiScrollBar = ^TbxMultiScrollBar;
  162.   TbxMultiScrollBar = Object(TScrollBar)
  163.     Destructor  Done;                                     Virtual;
  164.     Procedure   SetState(AState : Word;
  165.                          Enable : Boolean);               Virtual;
  166.   end;
  167.  
  168.  
  169.   PbxEditBuff = ^TbxEditBuff;
  170.   TbxEditBuff = Object(TScroller)
  171.     Buf       : PbxByteArray;   { pointer to raw data       }
  172.     BufSize   : Word;           { actual buffer size        }
  173.     ItemSize  : Byte;           { display size of each char }
  174.  
  175.     Constructor Init(Bounds       : TRect;
  176.                      Buff         : Pointer;
  177.                      BuffSize     : Word;
  178.                      ItemWidth    : Byte;
  179.                      AVScrollBar  : PScrollBar);
  180.     Constructor Load(var S: TStream);
  181.     Function    DataSize: Word;                           Virtual;
  182.     Procedure   GetData(var Rec);                         Virtual;
  183.     Function    GetOffset: Word;
  184.     Procedure   GetXY(var Pos : TPoint);
  185.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  186.     Procedure   SetData(var Rec);                         Virtual;
  187.     Procedure   SetXY(Pos : TPoint);
  188.     Procedure   Store(var S: TStream);
  189.   end;
  190.  
  191.  
  192.   PbxAsciiBuff = ^TbxAsciiBuff;
  193.   TbxAsciiBuff = Object(TbxEditBuff)
  194.     Constructor Init(Bounds       : TRect;
  195.                      Buff         : Pointer;
  196.                      BuffSize     : Word;
  197.                      AVScrollBar  : PScrollBar);
  198.     Procedure   Draw;                                     Virtual;
  199.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  200.   end;
  201.  
  202.  
  203.   PbxHexBuff = ^TbxHexBuff;
  204.   TbxHexBuff = Object(TbxEditBuff)
  205.     Constructor Init(Bounds       : TRect;
  206.                      Buff         : Pointer;
  207.                      BuffSize     : Word;
  208.                      AVScrollBar  : PScrollBar);
  209.     Procedure   Draw;                                     Virtual;
  210.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  211.   end;
  212.  
  213.  
  214.   PbxAsciiHexEditor = ^TbxAsciiHexEditor;
  215.   TbxAsciiHexEditor = Object(TbxWindow)
  216.     MaxPos      : Word;                   { highest position edited }
  217.     LView       : PbxEditBuff;            { left side HEX buffer    }
  218.     RView       : PbxEditBuff;            { right side ASCII buffer }
  219.     VScrollBar  : PbxMultiScrollBar;      { vertical scroll bar     }
  220.     Indicator   : PbxPosIndicator;        { byte position indicator }
  221.     Modified    : Boolean;
  222.  
  223.     Constructor Init(Bounds   : TRect;
  224.                      ATitle   : TTitleStr;
  225.                      ANumber  : Integer;
  226.                      AOptions : Word;
  227.                      Buff     : Pointer;
  228.                      BuffSize : Word);
  229.     Constructor Load(var S: TStream);
  230.     Function    DataSize: Word;                           Virtual;
  231.     Procedure   GetData(var Rec);                         Virtual;
  232.     Procedure   HandleEvent(var Event : TEvent);          Virtual;
  233.     Procedure   SetData(var Rec);                         Virtual;
  234.     Procedure   SetState(AState: Word; Enable: Boolean);  Virtual;
  235.     Procedure   SizeLimits(var Min, Max : TPoint);        Virtual;
  236.     Procedure   Store(var S: TStream);
  237.   end;
  238.  
  239.  
  240.   WinData = record
  241.     Device : PTextDevice;
  242.     Filler : Array [1..12] of Char;
  243.   end;
  244.  
  245.  
  246.   { Record used by the TbxFormattedTextScroller, TbxEditBuff,
  247.     and TbxASCIIHexEditor SetData methods.
  248.   }
  249.   TbxBufData = record
  250.     Data    : Pointer;
  251.     DataSize: Word;
  252.   end;
  253.  
  254.  
  255. { Redirect output to a PbxTextWindow. Set F to "Output" to redirect all
  256.   Writeln statements to the window.
  257. }
  258. Procedure AssignOutput(var F : Text; AWindow : PbxTextWindow);
  259.  
  260.  
  261. { TvViews registration procedure }
  262.  
  263. Procedure RegisterTVViews;
  264.  
  265.  
  266. { Stream Registration Records }
  267.  
  268. CONST
  269.   RbxFrame: TStreamRec = (
  270.     ObjType : 5100;
  271.     VmtLink : Ofs(TypeOf(TbxFrame)^);
  272.     Load    : @TbxFrame.Load;
  273.     Store   : @TbxFrame.Store
  274.   );
  275.  
  276.  
  277. CONST
  278.   RbxMinMaxButton: TStreamRec = (
  279.     ObjType : 5101;
  280.     VmtLink : Ofs(TypeOf(TbxMinMaxButton)^);
  281.     Load    : @TbxMinMaxButton.Load;
  282.     Store   : @TbxMinMaxButton.Store
  283.   );
  284.  
  285. CONST
  286.   RbxIcon: TStreamRec = (
  287.     ObjType : 5102;
  288.     VmtLink : Ofs(TypeOf(TbxIcon)^);
  289.     Load    : @TbxIcon.Load;
  290.     Store   : @TbxIcon.Store
  291.   );
  292.  
  293. CONST
  294.   RbxWindowIcon: TStreamRec = (
  295.     ObjType : 5103;
  296.     VmtLink : Ofs(TypeOf(TbxWindowIcon)^);
  297.     Load    : @TbxWindowIcon.Load;
  298.     Store   : @TbxWindowIcon.Store
  299.   );
  300.  
  301. CONST
  302.   RbxWindow: TStreamRec = (
  303.     ObjType : 5104;
  304.     VmtLink : Ofs(TypeOf(TbxWindow)^);
  305.     Load    : @TbxWindow.Load;
  306.     Store   : @TbxWindow.Store
  307.   );
  308.  
  309. CONST
  310.   RbxTextWindow: TStreamRec = (
  311.     ObjType : 5105;
  312.     VmtLink : Ofs(TypeOf(TbxTextWindow)^);
  313.     Load    : @TbxTextWindow.Load;
  314.     Store   : @TbxTextWindow.Store
  315.   );
  316.  
  317. CONST
  318.   RbxFormattedTextScroller: TStreamRec = (
  319.     ObjType : 5106;
  320.     VmtLink : Ofs(TypeOf(TbxFormattedTextScroller)^);
  321.     Load    : @TbxFormattedTextScroller.Load;
  322.     Store   : @TbxFormattedTextScroller.Store
  323.   );
  324.  
  325. CONST
  326.   RbxPosIndicator: TStreamRec = (
  327.     ObjType : 5107;
  328.     VmtLink : Ofs(TypeOf(TbxPosIndicator)^);
  329.     Load    : @TbxPosIndicator.Load;
  330.     Store   : @TbxPosIndicator.Store
  331.   );
  332.  
  333. CONST
  334.   RbxMultiScrollBar: TStreamRec = (
  335.     ObjType : 5108;
  336.     VmtLink : Ofs(TypeOf(TbxMultiScrollBar)^);
  337.     Load    : @TbxMultiScrollBar.Load;
  338.     Store   : @TbxMultiScrollBar.Store
  339.   );
  340.  
  341. CONST
  342.   RbxEditBuff: TStreamRec = (
  343.     ObjType : 5109;
  344.     VmtLink : Ofs(TypeOf(TbxEditBuff)^);
  345.     Load    : @TbxEditBuff.Load;
  346.     Store   : @TbxEditBuff.Store
  347.   );
  348.  
  349. CONST
  350.   RbxAsciiBuff: TStreamRec = (
  351.     ObjType : 5110;
  352.     VmtLink : Ofs(TypeOf(TbxAsciiBuff)^);
  353.     Load    : @TbxAsciiBuff.Load;
  354.     Store   : @TbxAsciiBuff.Store
  355.   );
  356.  
  357. CONST
  358.   RbxHexBuff: TStreamRec = (
  359.     ObjType : 5111;
  360.     VmtLink : Ofs(TypeOf(TbxHexBuff)^);
  361.     Load    : @TbxHexBuff.Load;
  362.     Store   : @TbxHexBuff.Store
  363.   );
  364.  
  365. CONST
  366.   RbxAsciiHexEditor: TStreamRec = (
  367.     ObjType : 5112;
  368.     VmtLink : Ofs(TypeOf(TbxAsciiHexEditor)^);
  369.     Load    : @TbxAsciiHexEditor.Load;
  370.     Store   : @TbxAsciiHexEditor.Store
  371.   );
  372.  
  373.